import React, { Component } from 'react';
//import { render } from 'react-dom';
import { connect } from 'react-redux'



let _this="";
let action="";
let action2="";
class Workflow extends React.Component{
    constructor(args){
        super(args);
       _this=this;
           console.log(this.props);
    }

    fn(){
        console.log();
       const node = _this.refs.input;
      var text = node.value.trim();
      if(text==""){
         text="this is hello word";
      }
      
    action=_this.props.onAddClick(text);
   
    node.value ='';
}       

        fn2(){
            _this.props.oncount(_this.props.index);
        }
        fn3(){
            
        }

   render(){
       //console.log( _this.props.getsate());
       return <div>
               <div><h1>{_this.props.index}</h1></div>
               <div><input ref="input"></input></div>
                <br/>
                <div><input type="button"  value="test" onClick={this.fn.bind(this)} /></div>
                <div ref="div">{_this.props.text}</div>
                <div><input type="button"  value="count" onClick={this.fn2} /></div>
                <div><h1>test4</h1></div>
          </div>;
    }

}
 

function toadd1(state={index:1},action){
    console.log("test"+action.index);
    switch (action.type){
        case "add":
        return Object.assign({},state,{index:action.index+1});
       default:
      return state;
    }
}

function getsate(state){
    return state;
}

function getActions(){
    return action;
}

 
export default connect(getsate,getActions)(Workflow)